//
//  QQManager.m
//  EasyToo
//
//  Created by YuanDee on 13-10-14.
//
//

#import "QQManager.h"
#import "ChargeQQRequest.h"
#import "ChargeQQResponse.h"
#import "ServerCommunicationManager.h"

@implementation QQManager
static QQManager* gManager = nil;


+ (QQManager*)shareManager
{
    if (gManager == nil) {
        gManager = [[QQManager alloc] init];
    }
    return gManager;
}


- (void)chargeQQWithQQNum:(NSString *)num cardNum:(NSString *)cardNum
{
    ChargeQQRequest *request = [[ChargeQQRequest alloc] initWithCardId:nil andQQNum:num andCardNum:cardNum Delegate:self];
    [[ServerCommunicationManager GetServerCommunication] sendRequest:request];
}



- (void)onRequestSuccess:(BaseResponse *)response
{
    if ([response isKindOfClass:[ChargeQQResponse class]])
    {
        [self handleQQChargeSuccess:(ChargeQQResponse*)response];
    }
}

- (void)onRequestFail:(BaseResponse *)response
{
    if ([response isKindOfClass:[ChargeQQResponse class]])
    {
        [self.delegate onChargeQQFinish:NO tn:nil];
    }
}

- (void)handleQQChargeSuccess:(ChargeQQResponse*)response
{
    NSString *tn = response.tn;
    if (tn)
    {
        [self.delegate onChargeQQFinish:YES tn:tn];
    }
    else
    {
        [self.delegate onChargeQQFinish:NO tn:nil];
    }
}

@end
